﻿using System.Web;
using Sherwood.SignOn.Server.Controllers;

namespace Sherwood.SignOn.Server.Models.ViewModels
{
    /// <summary>
    /// Base class for view models
    /// </summary>
    public class ViewModelBase
    {
        public string Host
        {
            get
            {
                string host = "";
                if (HttpContext.Current != null && HttpContext.Current.Request != null)
                {
                    host = HttpContext.Current.Request.Url.Host;
                    if (!HttpContext.Current.Request.Url.IsDefaultPort)
                    {
                        host += ":" + HttpContext.Current.Request.Url.Port;
                    }
                }
                return host;
            }
        }

        public string ProtocolAndHost
        {
            get
            {
                string host = "";
                if (HttpContext.Current != null && HttpContext.Current.Request != null)
                {
                    host = HttpContext.Current.Request.Url.Host;
                    if (!HttpContext.Current.Request.Url.IsDefaultPort)
                    {
                        host += ":" + HttpContext.Current.Request.Url.Port;
                    }
                    host = HttpContext.Current.Request.Url.Scheme + "://" + host;
                }
                return host;
            }
        }

        protected void SetCulture(params string[] cultures)
        {
            ControllerBase.SetCulture(cultures);
        }
    }
}